import { defineConfig } from 'vitepress'
// import { runCodeBlockPlugin, runCodeBlockClientScript } from './plugins/runCodeBlock.js'
import RunCode from './plugins'

const runCode = new RunCode()

// https://vitepress.dev/reference/site-config
export default defineConfig({
    title: "LangGraphJS 中文文档",
    description: "LangGraphJS 的中文文档和教程",
    lang: 'zh-CN',

    markdown: {
        config: (md) => {
            runCode.mdConfig(md)
        }
    },
    vite: {
        plugins: [
            runCode.vitePlugin()
        ]
    },
    head: [
        ['link', { rel: 'icon', href: '/logo.png' }],
        ['meta', { name: 'og:title', content: 'LangGraphJS 中文文档' }],
        ['meta', { name: 'og:description', content: 'LangGraphJS 的中文文档和教程' }],
    ],

    sitemap: {
        hostname: 'https://langgraphjs.org'
    },

    themeConfig: {
        // https://vitepress.dev/reference/default-theme-config
        logo: '/logo.png',

        editLink: {
            pattern: 'https://github.com/langchain-ai/langgraphjs/edit/main/docs/:path',
            text: '在 GitHub 上编辑此页'
        },

        nav: [
            { text: '首页', link: '/' },
            { text: '指南', link: '/guide/' },
            { text: '教程', link: '/tutorials/' },
            { text: '实战案例', link: '/examples/' },
            { text: 'API参考', link: '/reference/' },
            { text: 'MCP开发', link: '/mcp/' },
            { text: '测试', link: '/test/test-run-code' },
        ],

        sidebar: {
            '/guide/': [
                {
                    text: '指南',
                    items: [
                        { text: 'LangGraphJS 介绍', link: '/guide/' },
                        { text: '安装指南', link: '/guide/installation' },
                        { text: '快速开始', link: '/guide/getting-started' }
                    ]
                }
            ],
            '/mcp/': [
                {
                    text: 'MCP开发',
                    items: [
                        { text: 'MCP介绍', link: '/mcp/' },
                        { text: 'MCP原理', link: '/mcp/principles' },
                        { text: '开发第一个MCP', link: '/mcp/first-mcp' },
                        { text: 'MCP与LangGraphJS集成', link: '/mcp/integration' },
                        { text: 'MCP服务器架构', link: '/mcp/architecture' },
                        { text: '工具开发', link: '/mcp/tools' },
                        { text: '资源开发', link: '/mcp/resources' },
                        { text: '高级功能', link: '/mcp/advanced' },
                        { text: '部署与分享', link: '/mcp/deployment' },
                        { text: '最佳实践', link: '/mcp/best-practices' }
                    ]
                }
            ],
            '/tutorials/': [
                {
                    text: '教程',
                    items: [
                        { text: '教程概览', link: '/tutorials/' },
                        { text: '基础概念', link: '/tutorials/concepts' },
                        { text: '状态管理', link: '/tutorials/state-management' },
                        { text: '状态', link: '/tutorials/state' },
                        { text: '条件边缘', link: '/tutorials/conditional-edges' },
                        { text: '边缘', link: '/tutorials/edges' },
                        { text: '节点', link: '/tutorials/nodes' },
                        { text: '模块', link: '/tutorials/modules' },
                        { text: '人类反馈', link: '/tutorials/human-feedback' },
                        { text: '工具使用', link: '/tutorials/tool-use' },
                        { text: '多智能体系统', link: '/tutorials/multi-agent' }
                    ]
                }
            ],
            '/examples/': [
                {
                    text: '实战案例',
                    items: [
                        { text: '案例概览', link: '/examples/' },
                        { text: '简单对话系统', link: '/examples/simple-conversation' },
                        { text: '人类反馈', link: '/examples/human-feedback' },
                        { text: '工具使用', link: '/examples/tool-use' },
                        { text: '代理系统', link: '/examples/agent-loop' },
                        { text: '多智能体系统', link: '/examples/multi-agent' }
                    ]
                }
            ],
            '/reference/': [
                {
                    text: 'API参考',
                    items: [
                        { text: 'API概览', link: '/reference/' },
                        { text: '图构建', link: '/reference/graph' },
                        { text: '状态管理', link: '/reference/state' },
                        { text: '节点类型', link: '/reference/nodes' }
                    ]
                }
            ]
        },

        socialLinks: [
            { icon: 'github', link: 'https://github.com/langchain-ai/langgraphjs' }
        ],

        footer: {
            message: '基于 MIT 许可发布',
            copyright: 'Copyright © 2023-present LangChain'
        },

        search: {
            provider: 'local'
        },

        outline: {
            level: [2, 3],
            label: '本页目录'
        },

        docFooter: {
            prev: '上一页',
            next: '下一页'
        },

        lastUpdated: {
            text: '最后更新于',
            formatOptions: {
                dateStyle: 'full',
                timeStyle: 'medium'
            }
        }
    }
})
